qcodes.instrument_drivers.Keysight package
Subpackages
- qcodes.instrument_drivers.Keysight.keysightb1500 package
- Submodules
- qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1500_base module
- qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1500_module module
- qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1500_sampling_measurement module
- qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1511B module
- qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1517A module
- qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1520A module
- qcodes.instrument_drivers.Keysight.keysightb1500.KeysightB1530A module
- qcodes.instrument_drivers.Keysight.keysightb1500.constants module
- qcodes.instrument_drivers.Keysight.keysightb1500.message_builder module
- Module contents
- qcodes.instrument_drivers.Keysight.private package
Submodules
qcodes.instrument_drivers.Keysight.Infiniium module
- class qcodes.instrument_drivers.Keysight.Infiniium.DSOTimeAxisParam(xorigin: float, xincrement: float, points: int, **kwargs: Any)[source]
Bases:
ParameterTime axis parameter for the Infiniium series DSO.
Initialize time axis. If values are unknown, they can be initialized to zero and filled in later.
- __getitem__(keys: Any) SweepFixedValues
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- increment(value: Any) None
Increment the parameter with a value
- Parameters
value – Value to be added to the parameter.
- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: Optional[float] = None, num: Optional[int] = None) SweepFixedValues
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns
Collection of parameter values to be iterated over.
- Return type
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.Keysight.Infiniium.DSOFrequencyAxisParam(xorigin: float, xincrement: float, points: int, **kwargs: Any)[source]
Bases:
ParameterFrequency axis parameter for the Infiniium series DSO.
Initialize frequency axis. If values are unknown, they can be initialized to zero and filled in later.
- __getitem__(keys: Any) SweepFixedValues
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- increment(value: Any) None
Increment the parameter with a value
- Parameters
value – Value to be added to the parameter.
- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: Optional[float] = None, num: Optional[int] = None) SweepFixedValues
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns
Collection of parameter values to be iterated over.
- Return type
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.Keysight.Infiniium.DSOTraceParam(name: str, instrument: Union[InfiniiumChannel, InfiniiumFunction], channel: str, **kwargs: Any)[source]
Bases:
ParameterWithSetpointsTrace parameter for the Infiniium series DSO
Initialize DSOTraceParam bound to a specific channel.
- UNIT_MAP = {0: 'UNKNOWN', 1: 'V', 2: 's', 3: "''", 4: 'A', 5: 'dB'}
- property setpoints: Sequence[Parameter]
Overwrite setpoint parameter to update setpoints if auto_digitize is true
- update_setpoints(preamble: Optional[Sequence[str]] = None) None[source]
Update waveform parameters. Must be called before data acquisition if instr.cache_setpoints is False
- __getitem__(keys: Any) SweepFixedValues
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- increment(value: Any) None
Increment the parameter with a value
- Parameters
value – Value to be added to the parameter.
- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: Optional[float] = None, num: Optional[int] = None) SweepFixedValues
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns
Collection of parameter values to be iterated over.
- Return type
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- class qcodes.instrument_drivers.Keysight.Infiniium.AbstractMeasurementSubsystem(parent: InstrumentBase, name: str, **kwargs: Any)[source]
Bases:
InstrumentModuleSubmodule containing the measurement subsystem commands and associated parameters.
Note: these commands are executed on the waveform in the scope buffer. If you need to ensure a fresh value, run dso.digitize() prior to reading the measurement value.
Add parameters to measurement subsystem. Note: This should not be initialized directly, rather initialize BoundMeasurementSubsystem or UnboundMeasurementSubsystem.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.Infiniium.BoundMeasurement(parent: Union[InfiniiumChannel, InfiniiumFunction], name: str, **kwargs: Any)[source]
Bases:
AbstractMeasurementSubsystemInitialize measurement subsystem bound to a specific channel
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
- class qcodes.instrument_drivers.Keysight.Infiniium.UnboundMeasurement(parent: Infiniium, name: str, **kwargs: Any)[source]
Bases:
AbstractMeasurementSubsystemInitialize measurement subsystem where target is set by the parameter source.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
- class qcodes.instrument_drivers.Keysight.Infiniium.InfiniiumFunction(parent: Infiniium, name: str, channel: int, **kwargs: Any)[source]
Bases:
InstrumentChannelInitialize an infiniium channel.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.Infiniium.InfiniiumChannel(parent: Infiniium, name: str, channel: int, **kwargs: Any)[source]
Bases:
InstrumentChannelInitialize an infiniium channel.
- update_setpoints() None[source]
Update time axis and offsets for this channel. Calling this function is required when instr.cache_setpoints is True whenever the scope parameters are changed.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.Infiniium.Infiniium(name: str, address: str, timeout: float = 20, channels: int = 4, silence_pyvisapy_warning: bool = False, **kwargs: Any)[source]
Bases:
VisaInstrumentThis is the QCoDeS driver for the Keysight Infiniium oscilloscopes
Initialises the oscilloscope.
- Parameters
name – Name of the instrument used by QCoDeS
address – Instrument address as used by VISA
timeout – Visa timeout, in secs.
channels – The number of channels on the scope.
silence_pyvisapy_warning – Don’t warn about pyvisa-py at startup
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- update_all_setpoints() None[source]
Update the setpoints for all enabled channels. This method may be run at the beginning of a measurement rather than looping through each channel manually.
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- digitize(timeout: Optional[int] = None) None[source]
Digitize a full waveform and block until the acquisition is complete.
Warning: If using pyvisa_py as your visa library, this will not work with acquisitions longer than a single timeout period. If you require long acquisitions either use Keysight/NI Visa or set timeout to be longer than the expected acquisition time.
qcodes.instrument_drivers.Keysight.KeysightAgilent_33XXX module
- class qcodes.instrument_drivers.Keysight.KeysightAgilent_33XXX.OutputChannel(parent: Instrument, name: str, channum: int)[source]
Bases:
InstrumentChannelClass to hold the output channel of a waveform generator
- Parameters
parent – The instrument to which the channel is attached.
name – The name of the channel
channum – The number of the channel in question (1-2)
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.KeysightAgilent_33XXX.SyncChannel(parent: Instrument, name: str)[source]
Bases:
InstrumentChannelClass to hold the sync output. Has very few parameters for single channel instruments
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.KeysightAgilent_33XXX.WaveformGenerator_33XXX(name: str, address: str, silent: bool = False, **kwargs: Any)[source]
Bases:
KeysightErrorQueueMixin,VisaInstrumentQCoDeS driver for the Keysight/Agilent 33XXX series of waveform generators
- Parameters
name – The name of the instrument used internally by QCoDeS. Must be unique.
address – The VISA resource name.
silent – If True, no connect message is printed.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- error() Tuple[int, str]
Return the first error message in the queue. It also clears it from the error queue.
Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).
If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.
- Returns
The error code and the error message.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- flush_error_queue(verbose: bool = True) None
Clear the instrument error queue, and prints it.
- Parameters
verbose – If true, the error messages are printed. Default: True.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_34410A_submodules module
- class qcodes.instrument_drivers.Keysight.Keysight_34410A_submodules.Keysight_34410A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]
Bases:
_Keysight_344xxAThis is the qcodes driver for the Keysight 34410A Multimeter
Create an instance of the instrument.
- Parameters
name – Name used by QCoDeS. Appears in the DataSet
address – Visa-resolvable instrument address.
silent – If True, the connect_message of the instrument is supressed. Default: False
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- abort_measurement() None
Abort a measurement in progress, returning the instrument to the trigger idle state.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- autorange_once() None
Performs immediate autorange and then turns autoranging off.
The value of the range parameter is also updated.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- decrease_range(range_value: Optional[float] = None, decrease_by: int = - 1) None
Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
decrease_by – How much to decrease range by, default behavior is by a step of one.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- error() Tuple[int, str]
Return the first error message in the queue. It also clears it from the error queue.
Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).
If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.
- Returns
The error code and the error message.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- fetch() ndarray
Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.
This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.
- Returns
a 1D numpy array of all measured values that are currently in the reading memory
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- flush_error_queue(verbose: bool = True) None
Clear the instrument error queue, and prints it.
- Parameters
verbose – If true, the error messages are printed. Default: True.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- increase_range(range_value: Optional[float] = None, increase_by: int = 1) None
Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
increase_by – How much to increase range by, default behavior is by a step of one.
- init_measurement() None
Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.
This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.
Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- read() ndarray
Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.
This method is similar to calling
init_measurement()followed immediately byfetch().- Returns
a 1D numpy array of all measured values
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- reset() None
Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_34411A_submodules module
- class qcodes.instrument_drivers.Keysight.Keysight_34411A_submodules.Keysight_34411A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]
Bases:
_Keysight_344xxAThis is the qcodes driver for the Keysight 34411A Multimeter
Create an instance of the instrument.
- Parameters
name – Name used by QCoDeS. Appears in the DataSet
address – Visa-resolvable instrument address.
silent – If True, the connect_message of the instrument is supressed. Default: False
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- abort_measurement() None
Abort a measurement in progress, returning the instrument to the trigger idle state.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- autorange_once() None
Performs immediate autorange and then turns autoranging off.
The value of the range parameter is also updated.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- decrease_range(range_value: Optional[float] = None, decrease_by: int = - 1) None
Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
decrease_by – How much to decrease range by, default behavior is by a step of one.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- error() Tuple[int, str]
Return the first error message in the queue. It also clears it from the error queue.
Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).
If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.
- Returns
The error code and the error message.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- fetch() ndarray
Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.
This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.
- Returns
a 1D numpy array of all measured values that are currently in the reading memory
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- flush_error_queue(verbose: bool = True) None
Clear the instrument error queue, and prints it.
- Parameters
verbose – If true, the error messages are printed. Default: True.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- increase_range(range_value: Optional[float] = None, increase_by: int = 1) None
Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
increase_by – How much to increase range by, default behavior is by a step of one.
- init_measurement() None
Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.
This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.
Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- read() ndarray
Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.
This method is similar to calling
init_measurement()followed immediately byfetch().- Returns
a 1D numpy array of all measured values
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- reset() None
Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_34460A_submodules module
- class qcodes.instrument_drivers.Keysight.Keysight_34460A_submodules.Keysight_34460A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]
Bases:
_Keysight_344xxAThis is the qcodes driver for the Keysight 34460A Multimeter
Create an instance of the instrument.
- Parameters
name – Name used by QCoDeS. Appears in the DataSet
address – Visa-resolvable instrument address.
silent – If True, the connect_message of the instrument is supressed. Default: False
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- abort_measurement() None
Abort a measurement in progress, returning the instrument to the trigger idle state.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- autorange_once() None
Performs immediate autorange and then turns autoranging off.
The value of the range parameter is also updated.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- decrease_range(range_value: Optional[float] = None, decrease_by: int = - 1) None
Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
decrease_by – How much to decrease range by, default behavior is by a step of one.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- error() Tuple[int, str]
Return the first error message in the queue. It also clears it from the error queue.
Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).
If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.
- Returns
The error code and the error message.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- fetch() ndarray
Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.
This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.
- Returns
a 1D numpy array of all measured values that are currently in the reading memory
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- flush_error_queue(verbose: bool = True) None
Clear the instrument error queue, and prints it.
- Parameters
verbose – If true, the error messages are printed. Default: True.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- increase_range(range_value: Optional[float] = None, increase_by: int = 1) None
Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
increase_by – How much to increase range by, default behavior is by a step of one.
- init_measurement() None
Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.
This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.
Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- read() ndarray
Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.
This method is similar to calling
init_measurement()followed immediately byfetch().- Returns
a 1D numpy array of all measured values
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- reset() None
Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_34461A_submodules module
- class qcodes.instrument_drivers.Keysight.Keysight_34461A_submodules.Keysight_34461A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]
Bases:
_Keysight_344xxAThis is the qcodes driver for the Keysight 34461A Multimeter
Create an instance of the instrument.
- Parameters
name – Name used by QCoDeS. Appears in the DataSet
address – Visa-resolvable instrument address.
silent – If True, the connect_message of the instrument is supressed. Default: False
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- abort_measurement() None
Abort a measurement in progress, returning the instrument to the trigger idle state.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- autorange_once() None
Performs immediate autorange and then turns autoranging off.
The value of the range parameter is also updated.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- decrease_range(range_value: Optional[float] = None, decrease_by: int = - 1) None
Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
decrease_by – How much to decrease range by, default behavior is by a step of one.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- error() Tuple[int, str]
Return the first error message in the queue. It also clears it from the error queue.
Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).
If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.
- Returns
The error code and the error message.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- fetch() ndarray
Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.
This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.
- Returns
a 1D numpy array of all measured values that are currently in the reading memory
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- flush_error_queue(verbose: bool = True) None
Clear the instrument error queue, and prints it.
- Parameters
verbose – If true, the error messages are printed. Default: True.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- increase_range(range_value: Optional[float] = None, increase_by: int = 1) None
Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
increase_by – How much to increase range by, default behavior is by a step of one.
- init_measurement() None
Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.
This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.
Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- read() ndarray
Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.
This method is similar to calling
init_measurement()followed immediately byfetch().- Returns
a 1D numpy array of all measured values
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- reset() None
Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_34465A_submodules module
- class qcodes.instrument_drivers.Keysight.Keysight_34465A_submodules.Keysight_34465A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]
Bases:
_Keysight_344xxAThis is the qcodes driver for the Keysight 34465A Multimeter
Create an instance of the instrument.
- Parameters
name – Name used by QCoDeS. Appears in the DataSet
address – Visa-resolvable instrument address.
silent – If True, the connect_message of the instrument is supressed. Default: False
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- abort_measurement() None
Abort a measurement in progress, returning the instrument to the trigger idle state.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- autorange_once() None
Performs immediate autorange and then turns autoranging off.
The value of the range parameter is also updated.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- decrease_range(range_value: Optional[float] = None, decrease_by: int = - 1) None
Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
decrease_by – How much to decrease range by, default behavior is by a step of one.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- error() Tuple[int, str]
Return the first error message in the queue. It also clears it from the error queue.
Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).
If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.
- Returns
The error code and the error message.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- fetch() ndarray
Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.
This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.
- Returns
a 1D numpy array of all measured values that are currently in the reading memory
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- flush_error_queue(verbose: bool = True) None
Clear the instrument error queue, and prints it.
- Parameters
verbose – If true, the error messages are printed. Default: True.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- increase_range(range_value: Optional[float] = None, increase_by: int = 1) None
Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
increase_by – How much to increase range by, default behavior is by a step of one.
- init_measurement() None
Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.
This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.
Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- read() ndarray
Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.
This method is similar to calling
init_measurement()followed immediately byfetch().- Returns
a 1D numpy array of all measured values
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- reset() None
Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_34470A_submodules module
- class qcodes.instrument_drivers.Keysight.Keysight_34470A_submodules.Keysight_34470A(name: str, address: str, silent: bool = False, **kwargs: Any)[source]
Bases:
_Keysight_344xxAThis is the qcodes driver for the Keysight 34470A Multimeter
Create an instance of the instrument.
- Parameters
name – Name used by QCoDeS. Appears in the DataSet
address – Visa-resolvable instrument address.
silent – If True, the connect_message of the instrument is supressed. Default: False
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- abort_measurement() None
Abort a measurement in progress, returning the instrument to the trigger idle state.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- autorange_once() None
Performs immediate autorange and then turns autoranging off.
The value of the range parameter is also updated.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- decrease_range(range_value: Optional[float] = None, decrease_by: int = - 1) None
Decrease the voltage range by a certain amount with default of -1. If limit is reached, the min range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
decrease_by – How much to decrease range by, default behavior is by a step of one.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- error() Tuple[int, str]
Return the first error message in the queue. It also clears it from the error queue.
Up to 20 errors can be stored in the instrument’s error queue. Error retrieval is first-in-first-out (FIFO).
If more than 20 errors have occurred, the most recent error stored in the queue is replaced with -350,”Queue overflow”. No additional errors are stored until you remove errors from the queue. If no errors have occurred when you read the error queue, the instrument responds with +0,”No error”.
- Returns
The error code and the error message.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- fetch() ndarray
Waits for measurements to complete and copies all available measurements to the instrument’s output buffer. The readings remain in reading memory.
This query does not erase measurements from the reading memory. You can call this method multiple times to retrieve the same data.
- Returns
a 1D numpy array of all measured values that are currently in the reading memory
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- flush_error_queue(verbose: bool = True) None
Clear the instrument error queue, and prints it.
- Parameters
verbose – If true, the error messages are printed. Default: True.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- increase_range(range_value: Optional[float] = None, increase_by: int = 1) None
Increases the voltage range by a certain amount with default of 1. If limit is reached, the max range is used.
- Parameters
range_value – The desired voltage range needed. Expressed by power of 10^x range from -3 to 10
increase_by – How much to increase range by, default behavior is by a step of one.
- init_measurement() None
Change the state of the triggering system from “idle” to “wait-for-trigger”, and clear the previous set of measurements from reading memory.
This method is an “overlapped” command. This means that after executing it, you can send other commands that do not affect the measurements.
Storing measurements in reading memory with this method is faster than sending measurements to the instrument’s output buffer using read method (“READ?” command) (provided you do not fetch, “FETCh?” command, until done).
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- read() ndarray
Starts a new set of measurements, waits for all measurements to complete, and transfers all available measurements.
This method is similar to calling
init_measurement()followed immediately byfetch().- Returns
a 1D numpy array of all measured values
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- reset() None
Reset the instrument to factory defaults. Also updates the snapshot to reflect the new (default) values of parameters.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_B2962A module
- class qcodes.instrument_drivers.Keysight.Keysight_B2962A.B2962AChannel(parent: Instrument, name: str, chan: int)[source]
Bases:
InstrumentChannel- Parameters
parent – The instrument to which the channel is attached.
name – The name of the channel
chan – The number of the channel in question (1-2)
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.Keysight_B2962A.B2962A(name: str, address: str, **kwargs: Any)[source]
Bases:
VisaInstrumentThis is the qcodes driver for the Keysight B2962A 6.5 Digit Low Noise Power Source
Status: alpha-version. .. todo:
- Implement any remaining parameters supported by the device - Similar drivers have special handlers to map return values of 9.9e+37 to inf, is this needed?
- get_idn() Dict[str, Optional[str]][source]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_N5173B module
- class qcodes.instrument_drivers.Keysight.Keysight_N5173B.N5173B(name: str, address: str, **kwargs: Any)[source]
Bases:
N5183B- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_N5183B module
- class qcodes.instrument_drivers.Keysight.Keysight_N5183B.N5183B(name: str, address: str, **kwargs: Any)[source]
Bases:
N51x1- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() Dict[str, Optional[str]]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.Keysight_N6705B module
- class qcodes.instrument_drivers.Keysight.Keysight_N6705B.N6705BChannel(parent: Instrument, name: str, chan: int)[source]
Bases:
InstrumentChannel- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.Keysight_N6705B.N6705B(name: str, address: str, **kwargs: Any)[source]
Bases:
VisaInstrument- get_idn() Dict[str, Optional[str]][source]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.KtM960x module
- class qcodes.instrument_drivers.Keysight.KtM960x.Measure(name: str, instrument: KtM960x)[source]
Bases:
MultiParameter- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- get_raw() Tuple[Any, ...][source]
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- property full_names: tuple[str, ...]
Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to. The name parts are separated by underscores, like this:
instrument_submodule_parameter
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoint_full_names: collections.abc.Sequence[collections.abc.Sequence[str]] | None
Full names of setpoints including instrument names, if available
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- property short_names: tuple[str, ...]
short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.
It exists for consistency with instruments and other parameters.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.Keysight.KtM960x.KtM960x(name: str, address: str, options: str = '', dll_path: str = 'C:\\Program Files\\IVI Foundation\\IVI\\Bin\\KtM960x_64.dll', **kwargs: Any)[source]
Bases:
InstrumentProvide a wrapper for the Keysight KtM960x DAC. This driver provides an interface into the IVI-C driver provided by Keysight. The .dll is installed by default into C:Program FilesIVI FoundationIVIBinKtM960x_64.dll but a different path can be supplied to the constructor
- close() None[source]
Irreversibly stop this instrument and free its resources.
Subclasses should override this if they have other specific resources to close.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low level method to write to the hardware and return a response.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overrideask.- Parameters
cmd – The string to send to the instrument.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low level method to write a command string to the hardware.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overridewrite.- Parameters
cmd – The string to send to the instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.KtM960xDefs module
qcodes.instrument_drivers.Keysight.KtMAwg module
- class qcodes.instrument_drivers.Keysight.KtMAwg.KtMAWGChannel(parent: KtMAwg, name: str, chan: int)[source]
Bases:
InstrumentChannelRepresent the three channels of the Keysight KTM Awg driver. The channels can be independently controlled and programmed with seperate waveforms.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.KtMAwg.KtMAwg(name: str, address: str, options: str = '', dll_path: str = 'C:\\Program Files\\IVI Foundation\\IVI\\Bin\\KtMAwg_64.dll', **kwargs: Any)[source]
Bases:
InstrumentAWG Driver for the Keysight M9336A PXIe I/Q Arbitrary Waveform Generator. This driver provides a simple wrapper around the IVI-C drivers from Keysight. The output configuration, gain can be controlled and a waveform can be loaded from a file.
- close() None[source]
Irreversibly stop this instrument and free its resources.
Subclasses should override this if they have other specific resources to close.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low level method to write to the hardware and return a response.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overrideask.- Parameters
cmd – The string to send to the instrument.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low level method to write a command string to the hardware.
Subclasses that define a new hardware communication should override this method. Subclasses that transform
cmdshould instead overridewrite.- Parameters
cmd – The string to send to the instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.KtMAwgDefs module
qcodes.instrument_drivers.Keysight.N51x1 module
- class qcodes.instrument_drivers.Keysight.N51x1.N51x1(name: str, address: str, min_power: int = - 144, max_power: int = 19, **kwargs: Any)[source]
Bases:
VisaInstrumentThis is the qcodes driver for Keysight/Agilent scalar RF sources. It has been tested with N5171B, N5181A, N5173B, N5183B
- get_idn() Dict[str, Optional[str]][source]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.N5222B module
- class qcodes.instrument_drivers.Keysight.N5222B.N5222B(name: str, address: str, **kwargs: Any)[source]
Bases:
PNABaseDriver for Keysight PNA N5222B.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- get_trace_catalog() str
Get the trace catalog, that is a list of trace and sweep types from the PNA.
- The format of the returned trace is:
trace_name,trace_type,trace_name,trace_type…
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- select_trace_by_name(trace_name: str) int
Select a trace on the PNA by name.
- Returns
The trace number of the selected trace
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- property traces: ChannelList
Update channel list with active traces and return the new list
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.N5230C module
- class qcodes.instrument_drivers.Keysight.N5230C.N5230C(name: str, address: str, **kwargs: Any)[source]
Bases:
PNABase- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- get_trace_catalog() str
Get the trace catalog, that is a list of trace and sweep types from the PNA.
- The format of the returned trace is:
trace_name,trace_type,trace_name,trace_type…
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- select_trace_by_name(trace_name: str) int
Select a trace on the PNA by name.
- Returns
The trace number of the selected trace
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- property traces: ChannelList
Update channel list with active traces and return the new list
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.N5245A module
- class qcodes.instrument_drivers.Keysight.N5245A.N5245A(name: str, address: str, **kwargs: Any)[source]
Bases:
PNAxBase- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- get_trace_catalog() str
Get the trace catalog, that is a list of trace and sweep types from the PNA.
- The format of the returned trace is:
trace_name,trace_type,trace_name,trace_type…
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- select_trace_by_name(trace_name: str) int
Select a trace on the PNA by name.
- Returns
The trace number of the selected trace
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- property traces: ChannelList
Update channel list with active traces and return the new list
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.N52xx module
- class qcodes.instrument_drivers.Keysight.N52xx.PNAAxisParameter(startparam: Parameter, stopparam: Parameter, pointsparam: Parameter, **kwargs: Any)[source]
Bases:
ParameterAxis parameter for traces from the PNA
- __getitem__(keys: Any) SweepFixedValues
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- increment(value: Any) None
Increment the parameter with a value
- Parameters
value – Value to be added to the parameter.
- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: Optional[float] = None, num: Optional[int] = None) SweepFixedValues
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns
Collection of parameter values to be iterated over.
- Return type
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.Keysight.N52xx.PNALogAxisParamter(startparam: Parameter, stopparam: Parameter, pointsparam: Parameter, **kwargs: Any)[source]
Bases:
PNAAxisParameterAxis parameter for traces from the PNA
- get_raw() ndarray[source]
Return the axis values on a log scale, with values retrieved from the parent instrument
- __getitem__(keys: Any) SweepFixedValues
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- increment(value: Any) None
Increment the parameter with a value
- Parameters
value – Value to be added to the parameter.
- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: Optional[float] = None, num: Optional[int] = None) SweepFixedValues
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns
Collection of parameter values to be iterated over.
- Return type
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.Keysight.N52xx.PNATimeAxisParameter(startparam: Parameter, stopparam: Parameter, pointsparam: Parameter, **kwargs: Any)[source]
Bases:
PNAAxisParameterAxis parameter for traces from the PNA
- get_raw() ndarray[source]
Return the axis values on a time scale, with values retrieved from the parent instrument
- __getitem__(keys: Any) SweepFixedValues
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- increment(value: Any) None
Increment the parameter with a value
- Parameters
value – Value to be added to the parameter.
- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: Optional[float] = None, num: Optional[int] = None) SweepFixedValues
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns
Collection of parameter values to be iterated over.
- Return type
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.Keysight.N52xx.FormattedSweep(name: str, instrument: PNABase, sweep_format: str, label: str, unit: str, memory: bool = False, **kwargs: Any)[source]
Bases:
ParameterWithSetpointsMag will run a sweep, including averaging, before returning data. As such, wait time in a loop is not needed.
- property setpoints: Sequence[ParameterBase]
Overwrite setpoint parameter to ask the PNA what type of sweep
- get_raw() Sequence[float][source]
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- __getitem__(keys: Any) SweepFixedValues
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- increment(value: Any) None
Increment the parameter with a value
- Parameters
value – Value to be added to the parameter.
- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: Optional[float] = None, num: Optional[int] = None) SweepFixedValues
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns
Collection of parameter values to be iterated over.
- Return type
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- class qcodes.instrument_drivers.Keysight.N52xx.PNAPort(parent: PNABase, name: str, port: int, min_power: Union[int, float], max_power: Union[int, float], **kwargs: Any)[source]
Bases:
InstrumentChannelAllow operations on individual PNA ports. Note: This can be expanded to include a large number of extra parameters…
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.N52xx.PNATrace(parent: PNABase, name: str, trace_name: str, trace_num: int, **kwargs: Any)[source]
Bases:
InstrumentChannelAllow operations on individual PNA traces.
- run_sweep() str[source]
Run a set of sweeps on the network analyzer. Note that this will run all traces on the current channel.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.N52xx.PNABase(name: str, address: str, min_freq: Union[int, float], max_freq: Union[int, float], min_power: Union[int, float], max_power: Union[int, float], nports: int, **kwargs: Any)[source]
Bases:
VisaInstrumentBase qcodes driver for Agilent/Keysight series PNAs http://na.support.keysight.com/pna/help/latest/Programming/GP-IB_Command_Finder/SCPI_Command_Tree.htm
- Note: Currently this driver only expects a single channel on the PNA. We
can handle multiple traces, but using traces across multiple channels may have unexpected results.
- property traces: ChannelList
Update channel list with active traces and return the new list
- get_trace_catalog() str[source]
Get the trace catalog, that is a list of trace and sweep types from the PNA.
- The format of the returned trace is:
trace_name,trace_type,trace_name,trace_type…
- select_trace_by_name(trace_name: str) int[source]
Select a trace on the PNA by name.
- Returns
The trace number of the selected trace
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.N52xx.PNAxBase(name: str, address: str, min_freq: Union[int, float], max_freq: Union[int, float], min_power: Union[int, float], max_power: Union[int, float], nports: int, **kwargs: Any)[source]
Bases:
PNABase- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- get_trace_catalog() str
Get the trace catalog, that is a list of trace and sweep types from the PNA.
- The format of the returned trace is:
trace_name,trace_type,trace_name,trace_type…
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- select_trace_by_name(trace_name: str) int
Select a trace on the PNA by name.
- Returns
The trace number of the selected trace
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- property traces: ChannelList
Update channel list with active traces and return the new list
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
qcodes.instrument_drivers.Keysight.N9030B module
- class qcodes.instrument_drivers.Keysight.N9030B.FrequencyAxis(start: Parameter, stop: Parameter, npts: Parameter, *args: Any, **kwargs: Any)[source]
Bases:
Parameter- get_raw() Any[source]
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- __getitem__(keys: Any) SweepFixedValues
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- increment(value: Any) None
Increment the parameter with a value
- Parameters
value – Value to be added to the parameter.
- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: Optional[float] = None, num: Optional[int] = None) SweepFixedValues
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns
Collection of parameter values to be iterated over.
- Return type
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.Keysight.N9030B.Trace(number: int, *args: Any, **kwargs: Any)[source]
Bases:
ParameterWithSetpoints- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- get_raw() Any[source]
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- __getitem__(keys: Any) SweepFixedValues
Slice a Parameter to get a SweepValues object to iterate over during a sweep
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- increment(value: Any) None
Increment the parameter with a value
- Parameters
value – Value to be added to the parameter.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- set_raw(value: Any) None
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoints: Sequence[ParameterBase]
Sequence of parameters to use as setpoints for this parameter.
- Getter
Returns a list of parameters currently used for setpoints.
- Setter
Sets the parameters to be used as setpoints from a sequence. The combined shape of the parameters supplied must be consistent with the data shape of the data returned from get on the parameter.
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- sweep(start: float, stop: float, step: Optional[float] = None, num: Optional[int] = None) SweepFixedValues
Create a collection of parameter values to be iterated over. Requires start and stop and (step or num) The sign of step is not relevant.
- Parameters
start – The starting value of the sequence.
stop – The end value of the sequence.
step – Spacing between values.
num – Number of values to generate.
- Returns
Collection of parameter values to be iterated over.
- Return type
Examples
>>> sweep(0, 10, num=5) [0.0, 2.5, 5.0, 7.5, 10.0] >>> sweep(5, 10, step=1) [5.0, 6.0, 7.0, 8.0, 9.0, 10.0] >>> sweep(15, 10.5, step=1.5) >[15.0, 13.5, 12.0, 10.5]
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- class qcodes.instrument_drivers.Keysight.N9030B.SpectrumAnalyzerMode(parent: N9030B, name: str, *arg: Any, **kwargs: Any)[source]
Bases:
InstrumentChannelSpectrum Analyzer Mode for Keysight N9030B instrument.
- update_trace() None[source]
Updates start and stop frequencies whenever span of/or center frequency is updated.
- setup_swept_sa_sweep(start: float, stop: float, npts: int) None[source]
Sets up the Swept SA measurement sweep for Spectrum Analyzer Mode.
- autotune() None[source]
Autotune quickly get to the most likely signal of interest, and position it optimally on the display.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.N9030B.PhaseNoiseMode(parent: N9030B, name: str, *arg: Any, **kwargs: Any)[source]
Bases:
InstrumentChannelPhase Noise Mode for Keysight N9030B instrument.
- setup_log_plot_sweep(start_offset: float, stop_offset: float, npts: int) None[source]
Sets up the Log Plot measurement sweep for Phase Noise Mode.
- autotune() None[source]
On autotune, the measurement automatically searches for and tunes to the strongest signal in the full span of the analyzer.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.N9030B.N9030B(name: str, address: str, **kwargs: Any)[source]
Bases:
VisaInstrumentDriver for Keysight N9030B PXA signal analyzer. Keysight N9030B PXA siganl analyzer is part of Keysight X-Series Multi-touch Signal Analyzers. This driver allows Swept SA measurements in Spectrum Analyzer mode and Log Plot measurements in Phase Noise mode of the instrument.
- Parameters
name –
address –
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.P9374A module
- class qcodes.instrument_drivers.Keysight.P9374A.P9374A(name: str, address: str, **kwargs: Any)[source]
Bases:
PNAxBase- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- get_trace_catalog() str
Get the trace catalog, that is a list of trace and sweep types from the PNA.
- The format of the returned trace is:
trace_name,trace_type,trace_name,trace_type…
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- select_trace_by_name(trace_name: str) int
Select a trace on the PNA by name.
- Returns
The trace number of the selected trace
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- property traces: ChannelList
Update channel list with active traces and return the new list
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
qcodes.instrument_drivers.Keysight.keysight_34934a module
- class qcodes.instrument_drivers.Keysight.keysight_34934a.Keysight34934A(parent: Union[VisaInstrument, InstrumentChannel], name: str, slot: int)[source]
Bases:
KeysightSwitchMatrixSubModuleCreate an instance for module 34933A. :param parent: the system which the module is installed on :param name: user defined name for the module :param slot: the slot the module is installed
- write(cmd: str) None[source]
When the module is safety interlocked, users can not make any connections. There will be no effect when try to connect any channels.
- validate_value(row: int, column: int) None[source]
to check if the row and column number is within the range of the module layout.
- Parameters
row – row value
column – column value
- to_channel_list(paths: List[Tuple[int, int]], wiring_config: Optional[str] = '') str[source]
convert the (row, column) pair to a 4-digit channel number ‘sxxx’, where s is the slot number, xxx is generated from the numbering function.
- Parameters
paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]
wiring_config – for 1-wire matrices, values are ‘MH’, ‘ML’; for 2-wire matrices, values are ‘M1H’, ‘M2H’, ‘M1L’, ‘M2L’
- Returns
in the format of ‘(@sxxx, sxxx, sxxx, sxxx)’, where sxxx is a 4-digit channel number
- static get_numbering_function(rows: int, columns: int, wiring_config: Optional[str] = '') Callable[[int, int], str][source]
to select the correct numbering function based on the matrix layout. On P168 of the user’s guide for Agilent 34934A High Density Matrix Module: http://literature.cdn.keysight.com/litweb/pdf/34980-90034.pdf there are eleven equations. This function here simplifies them to one.
- Parameters
rows – the total row number of the matrix module
columns – the total column number of the matrix module
wiring_config – wiring configuration for 1 or 2 wired matrices
- Returns
The numbering function to convert row and column in to a 3-digit number
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- are_closed(paths: List[Tuple[int, int]]) List[bool]
to check if a list of channels is closed/connected
- Parameters
paths – list of channels [(r1, c1), (r2, c2), (r3, c3)]
- Returns
a list of True and/or False True if the channel is closed/connected False if it’s open/disconnected.
- are_open(paths: List[Tuple[int, int]]) List[bool]
to check if a list of channels is open/disconnected
- Parameters
paths – list of channels [(r1, c1), (r2, c2), (r3, c3)]
- Returns
a list of True and/or False True if the channel is closed/connected False if it’s open/disconnected.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- connect(row: int, column: int) None
to connect/close the specified channels
- Parameters
row – row number
column – column number
- connect_paths(paths: List[Tuple[int, int]]) None
to connect/close the specified channels.
- Parameters
paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- disconnect(row: int, column: int) None
to disconnect/open the specified channels
- Parameters
row – row number
column – column number
- disconnect_paths(paths: List[Tuple[int, int]]) None
to disconnect/open the specified channels.
- Parameters
paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- is_closed(row: int, column: int) bool
to check if a channel is closed/connected
- Parameters
row – row number
column – column number
- Returns
True if the channel is closed/connected False if it’s open/disconnected.
- is_open(row: int, column: int) bool
to check if a channel is open/disconnected
- Parameters
row – row number
column – column number
- Returns
True if the channel is open/disconnected False if it’s closed/connected.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.keysight_34980a module
- qcodes.instrument_drivers.Keysight.keysight_34980a.post_execution_status_poll(func: Callable[[...], T]) Callable[[...], T][source]
Generates a decorator that clears the instrument’s status registers before executing the actual call and reads the status register after the function call to determine whether an error occurs.
- Parameters
func – function to wrap
- class qcodes.instrument_drivers.Keysight.keysight_34980a.Keysight34980A(name: str, address: str, terminator: str = '\n', **kwargs: Any)[source]
Bases:
VisaInstrumentQCodes driver for 34980A switch/measure unit
Create an instance of the instrument.
- Parameters
name – Name of the instrument instance
address – Visa-resolvable instrument address.
- get_error() str[source]
Queries error queue
- Returns
error message, or ‘+0,”No error”’ if there is no error
- ask(cmd: str) str[source]
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write(cmd: str) None[source]
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- scan_slots() None[source]
Scan the occupied slots and make an object for each switch matrix module installed
- disconnect_all(slot: Optional[int] = None) None[source]
to open/disconnect all connections on select module
- Parameters
slot – slot number, between 1 and 8 (self._total_slot), default value is None, which means all slots
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.keysight_34980a_submodules module
- class qcodes.instrument_drivers.Keysight.keysight_34980a_submodules.KeysightSubModule(parent: Union[VisaInstrument, InstrumentChannel], name: str, slot: int)[source]
Bases:
InstrumentChannelA base class for submodules for the 34980A systems.
- Parameters
parent – the system which the module is installed on
name – user defined name for the module
slot – the slot the module is installed
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.keysight_34980a_submodules.KeysightSwitchMatrixSubModule(parent: Union[VisaInstrument, InstrumentChannel], name: str, slot: int)[source]
Bases:
KeysightSubModuleA base class for Switch Matrix submodules for the 34980A systems.
- validate_value(row: int, column: int) None[source]
to check if the row and column number is within the range of the module layout.
- Parameters
row – row value
column – column value
- to_channel_list(paths: List[Tuple[int, int]], wiring_config: Optional[str] = None) str[source]
convert the (row, column) pair to a 4-digit channel number ‘sxxx’, where s is the slot number, xxx is generated from the numbering function. This may be different for different modules.
- Parameters
paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]
wiring_config – for 1-wire matrices, values are ‘MH’, ‘ML’; for 2-wire matrices, values are ‘M1H’, ‘M2H’, ‘M1L’, ‘M2L’
- Returns
in the format of ‘(@sxxx, sxxx, sxxx, sxxx)’, where sxxx is a 4-digit channel number
- is_open(row: int, column: int) bool[source]
to check if a channel is open/disconnected
- Parameters
row – row number
column – column number
- Returns
True if the channel is open/disconnected False if it’s closed/connected.
- is_closed(row: int, column: int) bool[source]
to check if a channel is closed/connected
- Parameters
row – row number
column – column number
- Returns
True if the channel is closed/connected False if it’s open/disconnected.
- connect(row: int, column: int) None[source]
to connect/close the specified channels
- Parameters
row – row number
column – column number
- disconnect(row: int, column: int) None[source]
to disconnect/open the specified channels
- Parameters
row – row number
column – column number
- connect_paths(paths: List[Tuple[int, int]]) None[source]
to connect/close the specified channels.
- Parameters
paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]
- disconnect_paths(paths: List[Tuple[int, int]]) None[source]
to disconnect/open the specified channels.
- Parameters
paths – list of channels to connect [(r1, c1), (r2, c2), (r3, c3)]
- are_closed(paths: List[Tuple[int, int]]) List[bool][source]
to check if a list of channels is closed/connected
- Parameters
paths – list of channels [(r1, c1), (r2, c2), (r3, c3)]
- Returns
a list of True and/or False True if the channel is closed/connected False if it’s open/disconnected.
- are_open(paths: List[Tuple[int, int]]) List[bool][source]
to check if a list of channels is open/disconnected
- Parameters
paths – list of channels [(r1, c1), (r2, c2), (r3, c3)]
- Returns
a list of True and/or False True if the channel is closed/connected False if it’s open/disconnected.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- log: InstrumentLoggerAdapter = get_instrument_logger(self, __name__)
qcodes.instrument_drivers.Keysight.keysight_b220x module
- qcodes.instrument_drivers.Keysight.keysight_b220x.post_execution_status_poll(func: Callable[[...], T]) Callable[[...], T][source]
Generates a decorator that clears the instrument’s status registers before executing the actual call and reads the status register after the function call to determine whether an error occured.
- Parameters
func – function to wrap
- class qcodes.instrument_drivers.Keysight.keysight_b220x.KeysightB220X(name: str, address: str, **kwargs: Any)[source]
Bases:
VisaInstrumentQCodes driver for B2200 / B2201 switch matrix
Note: The B2200 consists of up to 4 modules and provides two channel configuration modes, Normal and Auto. The configuration mode defines whether multiple switch modules are treated as one (Auto mode), or separately (Normal mode). This driver only implements the Auto mode. Please read the manual section on Channel Configuration Mode for more info.
- connect(input_ch: int, output_ch: int) None[source]
Connect given input/output pair.
- Parameters
input_ch – Input channel number 1-14
output_ch – Output channel number 1-48
- disconnect(input_ch: int, output_ch: int) None[source]
Disconnect given Input/Output pair.
- Parameters
input_ch – Input channel number 1-14
output_ch – Output channel number 1-48
- disconnect_all() None[source]
opens all connections.
If ground or bias mode is enabled it will connect all outputs to the GND or Bias Port
- bias_disable_all_outputs() None[source]
Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.
- bias_enable_all_outputs() None[source]
Adds all outputs to list of ports that will be connected to bias input if port is unused and bias mode is enabled.
- bias_enable_output(output: int) None[source]
Adds output to list of ports that will be connected to bias input if port is unused and bias mode is enabled.
- Parameters
output – int 1-48
- bias_disable_output(output: int) None[source]
Removes output from list of ports that will be connected to bias input if port is unused and bias mode is enabled.
- Parameters
output – int 1-48
- gnd_enable_output(output: int) None[source]
Adds output to list of ports that will be connected to GND input if port is unused and bias mode is enabled.
- Parameters
output – int 1-48
- gnd_disable_output(output: int) None[source]
Removes output from list of ports that will be connected to GND input if port is unused and bias mode is enabled.
- Parameters
output – int 1-48
- gnd_enable_all_outputs() None[source]
Adds all outputs to list of ports that will be connected to GND input if port is unused and bias mode is enabled.
- gnd_disable_all_outputs() None[source]
Removes all outputs from list of ports that will be connected to GND input if port is unused and bias mode is enabled.
- couple_port_autodetect() None[source]
Autodetect Kelvin connections on Input ports
This will detect Kelvin connections on the input ports and enable couple mode for found kelvin connections. Kelvin connections must use input pairs that can be couple-enabled in order to be autodetected.
{(1, 2), (3, 4), (5, 6), (7, 8), (9, 10), (11, 12), (13, 14)}
Also refer to the manual for more information.
- static parse_channel_list(channel_list: str) Set[Tuple[int, int]][source]
Generate a set of (input, output) tuples from a SCPI channel list string.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
qcodes.instrument_drivers.Keysight.keysight_e4980a module
- class qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair(name: str, names: Sequence[str], units: Sequence[str], **kwargs: Any)[source]
Bases:
MultiParameterData class for E4980A measurement, which will always return two items at once.
The two items are for two different parameters, depending on the measurement function. Hence, the names of the two attributes are created from the “names” tuple of the measurement functions.
Examples
To create a measurement data with capacitance=1.2, and dissipation_factor=3.4.
>>> data = MeasurementPair(name="CPD", names=("capacitance", "dissipation_factor"), units=("F", "")) >>> data.set((1.2, 3.4)) >>> data.get() (1.2, 3.4)
- set_raw(value: Tuple[float, float]) None[source]
set_rawis called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.
- get_raw() Tuple[Any, ...][source]
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- property full_name: str
Name of the parameter including the name of the instrument and submodule that the parameter may be bound to. The names are separated by underscores, like this:
instrument_submodule_parameter.
- property full_names: tuple[str, ...]
Names of the parameter components including the name of the instrument and submodule that the parameter may be bound to. The name parts are separated by underscores, like this:
instrument_submodule_parameter
- get_ramp_values(value: float | collections.abc.Sized, step: Optional[float] = None) Sequence[float | collections.abc.Sized]
Return values to sweep from current value to target value. This method can be overridden to have a custom sweep behaviour. It can even be overridden by a generator.
- Parameters
value – target value
step – maximum step size
- Returns
List of stepped values, including target value.
- property instrument: InstrumentBase | None
Return the first instrument that this parameter is bound to. E.g if this is bound to a channel it will return the channel and not the instrument that the channel is bound too. Use
root_instrument()to get the real instrument.
- property inter_delay: float
Delay time between consecutive set operations. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay between sets.
- Getter
Returns the current inter_delay.
- Setter
Sets the value of the inter_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Name of the parameter. This is identical to
short_name().
- property post_delay: float
Delay time after start of set operation, for each set. The actual time will not be shorter than this, but may be longer if the underlying set call takes longer.
Typically used in conjunction with step to create an effective ramp rate, but can also be used without a step to enforce a delay after every set. One might think of post_delay as how long a set operation is supposed to take. For example, there might be an instrument that needs extra time after setting a parameter although the command for setting the parameter returns quickly.
- Getter
Returns the current post_delay.
- Setter
Sets the value of the post_delay.
- Raises
TypeError – If delay is not int nor float
ValueError – If delay is negative
- property raw_value: Any
Note that this property will be deprecated soon. Use
cache.raw_valueinstead.Represents the cached raw value of the parameter.
- Getter
Returns the cached raw value of the parameter.
- restore_at_exit(allow_changes: bool = True) _SetParamContext
Use a context manager to restore the value of a parameter after a
withblock.By default, the parameter value may be changed inside the block, but this can be prevented with
allow_changes=False. This can be useful, for example, for debugging a complex measurement that unintentionally modifies a parameter.Example
>>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.restore_at_exit(): ... p.set(3) ... print(f"value inside with block: {p.get()}") # prints 3 >>> print(f"value after with block: {p.get()}") # prints 2 >>> with p.restore_at_exit(allow_changes=False): ... p.set(5) # raises an exception
- property root_instrument: InstrumentBase | None
Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use
instrument()to get the channel.
- set_to(value: Any, allow_changes: bool = False) _SetParamContext
Use a context manager to temporarily set a parameter to a value. By default, the parameter value cannot be changed inside the context. This may be overridden with
allow_changes=True.Examples
>>> from qcodes.parameters import Parameter >>> p = Parameter("p", set_cmd=None, get_cmd=None) >>> p.set(2) >>> with p.set_to(3): ... print(f"p value in with block {p.get()}") # prints 3 ... p.set(5) # raises an exception >>> print(f"p value outside with block {p.get()}") # prints 2 >>> with p.set_to(3, allow_changes=True): ... p.set(5) # now this works >>> print(f"value after second block: {p.get()}") # still prints 2
- property setpoint_full_names: collections.abc.Sequence[collections.abc.Sequence[str]] | None
Full names of setpoints including instrument names, if available
- property short_name: str
Short name of the parameter. This is without the name of the instrument or submodule that the parameter may be bound to. For full name refer to
full_name().
- property short_names: tuple[str, ...]
short_names is identical to names i.e. the names of the parameter parts but does not add the instrument name.
It exists for consistency with instruments and other parameters.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the parameter as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).If the parameter has been initiated with
snapshot_value=False, the snapshot will NOT include thevalueandraw_valueof the parameter.- Parameters
update – If True, update the state by calling
parameter.get()unlesssnapshot_getof the parameter isFalse. IfupdateisNone, use the current value from thecacheunless the cache is invalid. IfFalse, never callparameter.get().params_to_skip_update – No effect but may be passed from superclass
- Returns
base snapshot
- property step: float | None
Stepsize that this Parameter uses during set operation. Stepsize must be a positive number or None. If step is a positive number, this is the maximum value change allowed in one hardware call, so a single set can result in many calls to the hardware if the starting value is far from the target. All but the final change will attempt to change by +/- step exactly. If step is None stepping will not be used.
- Getter
Returns the current stepsize.
- Setter
Sets the value of the step.
- Raises
TypeError – if step is set to not numeric or None
ValueError – if step is set to negative
TypeError – if step is set to not integer or None for an integer parameter
TypeError – if step is set to not a number on None
- property underlying_instrument: InstrumentBase | None
Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.
This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence
root_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- validate(value: Any) None
Validate the value supplied.
- Parameters
value – value to validate
- Raises
TypeError – If the value is of the wrong type.
ValueError – If the value is outside the bounds specified by the validator.
- class qcodes.instrument_drivers.Keysight.keysight_e4980a.E4980AMeasurements[source]
Bases:
objectAll the measurement function for E4980A LCR meter. See user’s guide P353 https://literature.cdn.keysight.com/litweb/pdf/E4980-90230.pdf?id=789356
- CPD(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: CPD at 139766794833008>
- CPQ(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: CPQ at 139766794836176>
- CPG(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: CPG at 139766794836224>
- CPRP(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: CPRP at 139766794833056>
- CSD(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: CSD at 139766794840976>
- CSQ(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: CSQ at 139766794834640>
- CSRS(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: CSRS at 139766794831472>
- LPD(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: LPD at 139766794838864>
- LPQ(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: LPQ at 139766794845008>
- LPG(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: LPG at 139766794845392>
- LPRP(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: LPRP at 139766794845776>
- LSD(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: LSD at 139766794846160>
- LSQ(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: LSQ at 139766794837280>
- LSRS(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: LSRS at 139766794832000>
- LSRD(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: LSRD at 139766794830416>
- RX(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: RX at 139766794835600>
- ZTD(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: ZTD at 139766794837808>
- ZTR(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: ZTR at 139766794832528>
- GB(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: GB at 139766794842032>
- YTD(*args: Any, **kwargs: Any) Optional[Any] = <qcodes.instrument_drivers.Keysight.keysight_e4980a.MeasurementPair: YTD at 139766794843088>
- class qcodes.instrument_drivers.Keysight.keysight_e4980a.Correction4980A(parent: VisaInstrument, name: str)[source]
Bases:
InstrumentChannelModule for correction settings.
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: InstrumentBase
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = False, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If
True, update the state by querying the instrument. If None update the state if known to be invalid. IfFalse, just use the latest values in memory and never update state.params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- class qcodes.instrument_drivers.Keysight.keysight_e4980a.KeysightE4980A(name: str, address: str, terminator: str = '\n', **kwargs: Any)[source]
Bases:
VisaInstrumentQCodes driver for E4980A Precision LCR Meter
Create an instance of the instrument.
- Parameters
name – Name of the instrument instance
address – Visa-resolvable instrument address.
- property correction: Correction4980A
- property measure_impedance: MeasurementPair
- property measurement: MeasurementPair
- __getitem__(key: str) collections.abc.Callable[[...], Any] | qcodes.parameters.parameter.Parameter
Delegate instrument[‘name’] to parameter or function ‘name’.
- add_function(name: str, **kwargs: Any) None
Bind one
Functionto this instrument.Instrument subclasses can call this repeatedly in their
__init__for every real function of the instrument.This functionality is meant for simple cases, principally things that map to simple commands like
*RST(reset) or those with just a few arguments. It requires a fixed argument count, and positional args only.Note
We do not recommend the usage of Function for any new driver. Function does not add any significant features over a method defined on the class.
- Parameters
name – How the Function will be stored within
instrument.Functionsand also how you address it using the shortcut methods:instrument.call(func_name, *args)etc.**kwargs – constructor kwargs for
Function
- Raises
KeyError – If this instrument already has a function with this name.
- add_parameter(name: str, parameter_class: Optional[type[qcodes.parameters.parameter_base.ParameterBase]] = None, **kwargs: Any) None
Bind one Parameter to this instrument.
Instrument subclasses can call this repeatedly in their
__init__for every real parameter of the instrument.In this sense, parameters are the state variables of the instrument, anything the user can set and/or get.
- Parameters
name – How the parameter will be stored within
parametersand also how you address it using the shortcut methods:instrument.set(param_name, value)etc.parameter_class – You can construct the parameter out of any class. Default
parameters.Parameter.**kwargs – Constructor arguments for
parameter_class.
- Raises
KeyError – If this instrument already has a parameter with this name and the parameter being replaced is not an abstract parameter.
ValueError – If there is an existing abstract parameter and the unit of the new parameter is inconsistent with the existing one.
- add_submodule(name: str, submodule: InstrumentModule | ChannelTuple) None
Bind one submodule to this instrument.
Instrument subclasses can call this repeatedly in their
__init__method for every submodule of the instrument.Submodules can effectively be considered as instruments within the main instrument, and should at minimum be snapshottable. For example, they can be used to either store logical groupings of parameters, which may or may not be repeated, or channel lists. They should either be an instance of an
InstrumentModuleor aChannelTuple.- Parameters
name – How the submodule will be stored within
instrument.submodulesand also how it can be addressed.submodule – The submodule to be stored.
- Raises
- property ancestors: list[qcodes.instrument.instrument_base.InstrumentBase]
Ancestors in the form of a list of
InstrumentBaseThe list starts with the current module then the parent and the parents parent until the root instrument is reached.
- ask(cmd: str) str
Write a command string to the hardware and return a response.
Subclasses that transform
cmdshould override this method, and in it callsuper().ask(new_cmd). Subclasses that define a new hardware communication should instead overrideask_raw.- Parameters
cmd – The string to send to the instrument.
- Returns
response
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- ask_raw(cmd: str) str
Low-level interface to
visa_handle.ask.- Parameters
cmd – The command to send to the instrument.
- Returns
The instrument’s response.
- Return type
- call(func_name: str, *args: Any) Any
Shortcut for calling a function from its name.
- Parameters
func_name – The name of a function of this instrument.
*args – any arguments to the function.
- Returns
The return value of the function.
- classmethod close_all() None
Try to close all instruments registered in
_all_instrumentsThis is handy for use with atexit to ensure that all instruments are closed when a python session is closed.Examples
>>> atexit.register(qc.Instrument.close_all())
- connect_message(idn_param: str = 'IDN', begin_time: Optional[float] = None) None
Print a standard message on initial connection to an instrument.
- Parameters
idn_param – Name of parameter that returns ID dict. Default
IDN.begin_time –
time.time()when init started. Default isself._t0, set at start ofInstrument.__init__.
- delegate_attr_dicts: List[str] = ['parameters', 'functions', 'submodules']
A list of names (strings) of dictionaries which are (or will be) attributes of
self, whose keys should be treated as attributes ofself.
- delegate_attr_objects: List[str] = []
A list of names (strings) of objects which are (or will be) attributes of
self, whose attributes should be passed through toself.
- static exist(name: str, instrument_class: Optional[type] = None) bool
Check if an instrument with a given names exists (i.e. is already instantiated).
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- classmethod find_instrument(name: str, instrument_class: Optional[type[T]] = None) T
Find an existing instrument by name.
- Parameters
name – Name of the instrument.
instrument_class – The type of instrument you are looking for.
- Returns
The instrument found.
- Raises
- property full_name: str
Full name of the instrument.
For an
InstrumentModulethis includes all parents separated by_
- get(param_name: str) Any
Shortcut for getting a parameter from its name.
- Parameters
param_name – The name of a parameter of this instrument.
- Returns
The current value of the parameter.
- get_idn() dict[str, str | None]
Parse a standard VISA
*IDN?response into an ID dict.Even though this is the VISA standard, it applies to various other types as well, such as IPInstruments, so it is included here in the Instrument base class.
Override this if your instrument does not support
*IDN?or returns a nonstandard IDN string. This string is supposed to be a comma-separated list of vendor, model, serial, and firmware, but semicolon and colon are also common separators so we accept them here as well.- Returns
A dict containing vendor, model, serial, and firmware.
- classmethod instances() list[qcodes.instrument.instrument.Instrument]
Get all currently defined instances of this instrument class.
You can use this to get the objects back if you lose track of them, and it’s also used by the test system to find objects to test against.
- Returns
A list of instances.
- invalidate_cache() None
Invalidate the cache of all parameters on the instrument. Calling this method will recursively mark the cache of all parameters on the instrument and any parameter on instrument modules as invalid.
This is useful if you have performed manual operations (e.g. using the frontpanel) which changes the state of the instrument outside QCoDeS.
This in turn means that the next snapshot of the instrument will trigger a (potentially slow) reread of all parameters of the instrument if you pass update=None to snapshot.
- static is_valid(instr_instance: Instrument) bool
Check if a given instance of an instrument is valid: if an instrument has been closed, its instance is not longer a “valid” instrument.
- Parameters
instr_instance – Instance of an Instrument class or its subclass.
- load_metadata(metadata: Mapping[str, Any]) None
Load metadata into this classes metadata dictionary.
- Parameters
metadata – Metadata to load.
- property name: str
Full name of the instrument
This is equivalent to
full_name()for backwards compatibility.
- property name_parts: list[str]
A list of all the parts of the instrument name from
root_instrument()to the currentInstrumentModule.
- omit_delegate_attrs: List[str] = []
A list of attribute names (strings) to not delegate to any other dictionary or object.
- property parent: qcodes.instrument.instrument_base.InstrumentBase | None
The parent instrument. By default, this is
None. Any SubInstrument should subclass this to return the parent instrument.
- print_readable_snapshot(update: bool = False, max_chars: int = 80) None
Prints a readable version of the snapshot. The readable snapshot includes the name, value and unit of each parameter. A convenience function to quickly get an overview of the status of an instrument.
- Parameters
update – If
True, update the state by querying the instrument. IfFalse, just use the latest values in memory. This argument gets passed to the snapshot function.max_chars – the maximum number of characters per line. The readable snapshot will be cropped if this value is exceeded. Defaults to 80 to be consistent with default terminal width.
- classmethod record_instance(instance: Instrument) None
Record (a weak ref to) an instance in a class’s instance list.
Also records the instance in list of all instruments, and verifies that there are no other instruments with the same name.
This method is called after initialization of the instrument is completed.
- Parameters
instance – Instance to record.
- Raises
KeyError – If another instance with the same name is already present.
- classmethod remove_instance(instance: Instrument) None
Remove a particular instance from the record.
- Parameters
instance – The instance to remove
- property root_instrument: InstrumentBase
The topmost parent of this module.
For the
root_instrumentthis isself.
- set(param_name: str, value: Any) None
Shortcut for setting a parameter from its name and new value.
- Parameters
param_name – The name of a parameter of this instrument.
value – The new value to set.
- set_address(address: str) None
Set the address for this instrument.
- Parameters
address – The visa resource name to use to connect. The address should be the actual address and just that. If you wish to change the backend for VISA, use the self.visalib attribute (and then call this function).
- set_terminator(terminator: str | None) None
Change the read terminator to use.
- Parameters
terminator – Character(s) to look for at the end of a read and to end each write command with. eg.
\r\n. If None the terminator will not be set.
- property short_name: str
Short name of the instrument.
For an
InstrumentModulethis does not include any parent names.
- snapshot(update: Optional[bool] = False) Dict[str, Any]
Decorate a snapshot dictionary with metadata. DO NOT override this method if you want metadata in the snapshot instead, override
snapshot_base().- Parameters
update – Passed to snapshot_base.
- Returns
Base snapshot.
- snapshot_base(update: bool | None = True, params_to_skip_update: Optional[Sequence[str]] = None) dict[Any, Any]
State of the instrument as a JSON-compatible dict (everything that the custom JSON encoder class
NumpyJSONEncodersupports).- Parameters
update – If True, update the state by querying the instrument. If None only update if the state is known to be invalid. If False, just use the latest values in memory and never update.
params_to_skip_update – List of parameter names that will be skipped in update even if update is True. This is useful if you have parameters that are slow to update but can be updated in a different way (as in the qdac). If you want to skip the update of certain parameters in all snapshots, use the
snapshot_getattribute of those parameters instead.
- Returns
base snapshot
- Return type
- validate_status(verbose: bool = False) None
Validate the values of all gettable parameters
The validation is done for all parameters that have both a get and set method.
- Parameters
verbose – If
True, then information about the parameters that are being check is printed.
- write(cmd: str) None
Write a command string with NO response to the hardware.
Subclasses that transform
cmdshould override this method, and in it callsuper().write(new_cmd). Subclasses that define a new hardware communication should instead overridewrite_raw.- Parameters
cmd – The string to send to the instrument.
- Raises
Exception – Wraps any underlying exception with extra context, including the command and the instrument.
- write_raw(cmd: str) None
Low-level interface to
visa_handle.write.- Parameters
cmd – The command to send to the instrument.
- visa_handle: pyvisa.resources.MessageBasedResource = visa_handle
The VISA resource used by this instrument.
- parameters: dict[str, ParameterBase] = {}
All the parameters supported by this instrument. Usually populated via
add_parameter().
- functions: dict[str, Function] = {}
All the functions supported by this instrument. Usually populated via
add_function().
- submodules: dict[str, InstrumentModule | ChannelTuple] = {}
All the submodules of this instrument such as channel lists or logical groupings of parameters. Usually populated via
add_submodule().
- instrument_modules: dict[str, InstrumentModule] = {}
All the
InstrumentModuleof this instrument Usually populated viaadd_submodule().
- system_errors() str[source]
Returns the oldest unread error message from the event log and removes it from the log.